]> dgit.raspbian.org Git - gnome-shell.git/commitdiff
search: copy result to clipboard if requested
authorDaiki Ueno <dueno@src.gnome.org>
Wed, 3 May 2017 08:28:31 +0000 (10:28 +0200)
committerDaiki Ueno <dueno@src.gnome.org>
Thu, 11 May 2017 09:11:22 +0000 (11:11 +0200)
Some search providers such as GNOME Characters want to copy search
results to clipboard.  However, on Wayland, clipboards are only
accessible from applications that have a visible surface on display.

This patch allows a search provider to request the shell to copy a
search result to clipboard when 'clipboardText' is included in the meta
of the result.

https://bugzilla.gnome.org/show_bug.cgi?id=775099

js/ui/remoteSearch.js
js/ui/search.js

index baeaa126908960147b48c294df35cbf37697a6be..4f376bc31c38ba0526c0e3c0b2cd74308fdc7a96 100644 (file)
@@ -278,7 +278,8 @@ const RemoteSearchProvider = new Lang.Class({
                                name: metas[i]['name'],
                                description: metas[i]['description'],
                                createIcon: Lang.bind(this,
-                                                     this.createIcon, metas[i]) });
+                                                     this.createIcon, metas[i]),
+                               clipboardText: metas[i]['clipboardText'] });
         }
         callback(resultMetas);
     },
index 2ea1afb62e320b532b0ad4c3f5ada822160419e5..4d29e59efbefc04e77f1c8985759b5ffb357626e 100644 (file)
@@ -152,6 +152,8 @@ const SearchResultsBase = new Lang.Class({
 
         this._resultDisplays = {};
 
+        this._clipboard = St.Clipboard.get_default();
+
         this._cancellable = new Gio.Cancellable();
     },
 
@@ -181,6 +183,8 @@ const SearchResultsBase = new Lang.Class({
 
     _activateResult: function(result, id) {
         this.provider.activateResult(id, this._terms);
+        if (result.metaInfo.clipboardText)
+            this._clipboard.set_text(St.ClipboardType.CLIPBOARD, result.metaInfo.clipboardText);
         Main.overview.toggle();
     },